/*  1:   */ package org.jetbrains.io;
/*  2:   */ 
/*  3:   */

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.concurrent.TimeUnit;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */ 
/* 13:   */ public final class LocalFileFinder
/* 14:   */ {
/* 15:   */   private static final int a = 10;
/* 16:18 */   private static final Cache<Character, Boolean> b = CacheBuilder.newBuilder().expireAfterWrite(5L, TimeUnit.MINUTES).build();
/* 17:   */   
/* 18:   */   @Nullable
/* 19:   */   public static VirtualFile findFile(@NotNull String paramString)
/* 20:   */   {
/* 21:31 */     if (paramString == null) {
/* 22:31 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/io/LocalFileFinder", "findFile" }));
/* 23:   */     }
/* 24:31 */     if (windowsDriveExists(paramString)) {
/* 25:32 */       return LocalFileSystem.getInstance().findFileByPath(paramString);
/* 26:   */     }
/* 27:34 */     return null;
/* 28:   */   }
/* 29:   */   
/* 30:   */   public static boolean windowsDriveExists(@NotNull String paramString)
/* 31:   */   {
/* 32:38 */     if (paramString == null) {
/* 33:38 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/io/LocalFileFinder", "windowsDriveExists" }));
/* 34:   */     }
/* 35:38 */     if (!SystemInfo.isWindows) {
/* 36:38 */       return true;
/* 37:   */     }
/* 38:40 */     if ((paramString.length() > 2) && (Character.isLetter(paramString.charAt(0))) && (paramString.charAt(1) == ':'))
/* 39:   */     {
/* 40:41 */       char c = Character.toUpperCase(paramString.charAt(0));
/* 41:42 */       Boolean localBoolean = (Boolean)b.getIfPresent(Character.valueOf(c));
/* 42:43 */       if (localBoolean != null) {
/* 43:44 */         return localBoolean.booleanValue();
/* 44:   */       }
/* 45:47 */       long l = System.currentTimeMillis();
/* 46:48 */       boolean bool = new File(c + ":" + File.separator).exists();
/* 47:49 */       if (System.currentTimeMillis() - l > 10L) {
/* 48:50 */         bool = false;
/* 49:   */       }
/* 50:53 */       b.put(Character.valueOf(c), Boolean.valueOf(bool));
/* 51:54 */       return bool;
/* 52:   */     }
/* 53:58 */     return false;
/* 54:   */   }
/* 55:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.io.LocalFileFinder

 * JD-Core Version:    0.7.0.1

 */